<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Http
 *
 * @author miho
 */
class BluesCoders_Request_Http {

    protected $_parameters = array();
    protected $_attributes = array();
    protected $_uri;
    protected $_isForwarded = false;
    protected $_session;

    public function  __construct() {
        $this->_parameters = $_POST;
        unset($_POST);
        
        $this->_uri = $_SERVER['REQUEST_URI'];
        $this->_attributes = array();
    }

    public function getParameter($key, $default = null) {
        return isset($this->_parameters[$key]) ? $this->_parameters[$key] : $default;
    }

    public function getAttribute($key, $default = null) {
        return isset($this->_attributes[$key]) ? $this->_attributes[$key] : $default;
    }

    public function setAttribute($key, $value) {
        $this->_attributes[$key] = $value;
    }

    public function getAttributes() {
        return $this->_attributes;
    }

    public function getParameters() {
        return $this->_parameters;
    }

    public function getUri() {
        return $this->_uri;
    }

    public function isForwarded() {
        return $this->_isForwarded;
    }

    public function forward($uri) {
        $this->_uri = $uri;
        $this->_isForwarded = true;
    }

    /**
     *
     * @return BluesCoders_Request_Http_Session 
     */
    public function getSession() {
        if($this->_session == null) {
            require_once 'BluesCoders/Request/Http/Session.php';
            $this->_session = new BluesCoders_Request_Http_Session();
        }

        return $this->_session;
    }

}
?>
